Skip to main content

Message

note you can use v chat test server base url is http://170.178.195.150:81/api/v1/

1 - Get all message by room and loadMore

  • URL: {{baseUrl}}message?lastId=first&roomId=61cd92223bd8731be040e11e
  • Method: GET
  • Content-Type: JSON
  • Authentication: Bearer token is required in header in authorization : Bearer yourToken
  • Example request data in query param put:
{
"lastId":"first",
"roomId":"61cd92223bd8731be040e11e"
}
ParameterRequiredDescription
lastIdtrueif you pass first then will get you first 30 message to get next messages you need to pass the last message id in your list
roomIdtrueroom id

Example response:

{
"success": true,
"data": [
{
"_id": "61cd922a3bd8731be040e138",
"messageType": "text",
"messageAttachment": null,
"createdAt": 1640862250273,
"content": "first",
"senderId": "61cd8fb33bd8731be040e103",
"senderName": "user1 updated name",
"senderImageThumb": "REGISTER_3c651b24-3912-4191-a131-af99292a75f9_THUMB.jpg",
"roomId": "61cd92223bd8731be040e11e"
},
{
"_id": "61cd92223bd8731be040e128",
"messageType": "text",
"messageAttachment": null,
"createdAt": 1640862242839,
"content": "first",
"senderId": "61cd8fb33bd8731be040e103",
"senderName": "user1 updated name",
"senderImageThumb": "REGISTER_3c651b24-3912-4191-a131-af99292a75f9_THUMB.jpg",
"roomId": "61cd92223bd8731be040e11e"
}
]
}
  • messageType all available types is
  • [text, voice, image, video, file, reply, allDeleted, location, forward, create, join, leave, upgrade, downgrade, info, kick, add]

2 - Create Message to chat

1 send text message

  • URL: {{baseUrl}}message/single or {{baseUrl}}message/group for group chat
  • Method: POST
  • Content-Type: form-data to send image or attachment
  • Authentication: Bearer token is required in header in authorization : Bearer yourToken
  • Example request data:
{
"content":"message text",
"roomId":"61cd92223bd8731be040e11e",
"type":"text"
}
ParameterRequiredDescription
contenttruemessage text if image pass this content is image
roomIdtrueroom id
typetruemessage type it can be [text,image,voice,video,file]

Example response:

{
"success": true,
"data": "success to send to single chat"
}

don't add the message manually to your design you will receive the message in socket message name space

2 send image message

  • URL: {{baseUrl}}message/single or {{baseUrl}}message/group for group chat
  • Method: POST
  • Content-Type: form-data to send image or attachment
  • Authentication: Bearer token is required in header in authorization : Bearer yourToken
  • Example request data:
{
"content":"This content image ๐Ÿ“ท",
"roomId":"61cd92223bd8731be040e11e",
"type":"image",
"file":"mutil part file",
"attachment":{
"fileSize:"100 kb",
"height":"100",
"width":"200"
}
}
ParameterRequiredDescription
contenttruemessage text if image pass this content is image
roomIdtrueroom id
filetrueimage file to send
typetruemessage type it can be [text,image,voice,video,file]
attachmenttrue if type not textget image data and pass it {"fileSize:"100 kb","height":"100","width":"200"}

Example response:

{
"success": true,
"data": "success to send to single chat"
}

3 send voice message

  • URL: {{baseUrl}}message/single or {{baseUrl}}message/group for group chat
  • Method: POST
  • Content-Type: form-data to send image or attachment
  • Authentication: Bearer token is required in header in authorization : Bearer yourToken
  • Example request data:
{
"content":"This content voice ๐ŸŽค",
"roomId":"61cd92223bd8731be040e11e",
"type":"voice",
"file":"mutil part file",
"attachment":{
"fileSize:"200 kb",
"fileDuration":"00:10"
}
}
ParameterRequiredDescription
contenttruemessage text if image pass this content is image
roomIdtrueroom id
filetruevoice file to send
typetruemessage type it can be [text,image,voice,video,file]
attachmenttrue if type not textget voice data and pass it {"fileSize:"200 kb","fileDuration":"00:10"}

Example response:

{
"success": true,
"data": "success to send to single chat"
}

4 send video message

  • URL: {{baseUrl}}message/single or {{baseUrl}}message/group for group chat
  • Method: POST
  • Content-Type: form-data to send image or attachment
  • Authentication: Bearer token is required in header in authorization : Bearer yourToken
  • Example request data:
{
"content":"This content video ๐Ÿ“ฝ",
"roomId":"61cd92223bd8731be040e11e",
"type":"video",
"file":[mutil part video thumb image , mutil part video file],
"attachment":{
"fileSize:"200 kb",
"fileDuration":"00:10",
"height":"100", // video thumnal image height
"width":"200" // video thumnal image width
}
}
ParameterRequiredDescription
contenttruemessage text if image pass this content is image
roomIdtrueroom id
filetrueist array of muti part => first mutil part file is video thumb second is video file dont change this order
typetruemessage type it can be [text,image,voice,video,file]
attachmenttrue if type not textget voice data and pass it {"fileSize:"200 kb","fileDuration":"00:10","height":"100","width":"200"}

Example response:

{
"success": true,
"data": "success to send to single chat"
}

5 send video message

  • URL: {{baseUrl}}message/single or {{baseUrl}}message/group for group chat
  • Method: POST
  • Content-Type: form-data to send image or attachment
  • Authentication: Bearer token is required in header in authorization : Bearer yourToken
  • Example request data:
{
"content":"This content file ๐Ÿ“",
"roomId":"61cd92223bd8731be040e11e",
"type":"file",
"file":"mutil part file to send",
"attachment":{
"fileSize:"200 kb",
"linkTitle":"this is file name"
}
}
ParameterRequiredDescription
contenttruemessage text if image pass this content is image
roomIdtrueroom id
filetruemutil part file to send
typetruemessage type it can be [text,image,voice,video,file]
attachmenttrue if type not textget voice data and pass it {"fileSize:"200 kb","linkTitle":"this is file name"}

Example response:

{
"success": true,
"data": "success to send to single chat"
}